/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pradoeditor.comun;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URL;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
import pradoeditor.comun.logger.CustomLogger;

/**
 *
 * @author jaimeg
 */
public class WriteProperty
{
    private String file;

    public WriteProperty(String file)
    {
        this.file = file;
    }

    public void writeproperty(String key, String value)
    {
        try 
        {
            Properties properties = new Properties();
            URL url = ClassLoader.getSystemResource(getFile() + ".properties");
            properties.load(new FileInputStream(new File(url.getFile())));

            properties.setProperty(key, value);
            properties.store(new FileOutputStream( new File(url.getFile() + ".properties")),null);
        }
        catch (IOException ex)
        {
            CustomLogger.writeError(WriteProperty.class.getName(), ex);
        }
    }

    /**
     * @return the file
     */
    public String getFile() {
        return file;
    }

    /**
     * @param file the file to set
     */
    public void setFile(String file) {
        this.file = file;
    }
}
